local BackCards = fk.CreateSkill {
  name = "#BackCards",
}
---@class Utility_LB_Kill
local LB_U = require "packages.lb_kill_utility._base"

Fk:loadTranslationTable {
  ["#BackCards"] = "背置",
  ["@@BackCards-inhand"] = "背置",
  ["@@BackCards-inhand-round"] = "背置",
  ["@@BackCards-inhand-turn"] = "背置",
  ["@@BackCards-inhand-phase"] = "背置",
}


BackCards:addEffect("visibility", { -- 修改自爻疑
  card_visible = function(self, player, card)
    if LB_U.isBackCards(card) then
      local p = Fk:currentRoom():getCardOwner(card)
      if p then
        return player ~= p
      end
    end
  end,
  --[[
    if Fk:currentRoom():getBanner("RoundCount") == nil then
      --卡个小bug，用来实现刷卡时手牌不可见
      local p = Fk:currentRoom():getCardOwner(card)
      --if p and p:hasSkill(skel.name) then -- 不考虑技能失效了
      if p then
        return player ~= p
      end
    else
      if card:getMark("lb_zero__cuishan-inhand") > 0 then
        return not table.contains(player:getCardIds("h"), card.id)
      end
    end
  end,

  move_visible = function(self, player, info, move)
    if move.to == player and move.skillName == "chenwei" then
      --FIXME：好像没用？
      return false
    end
  end
  --]]
})

BackCards:addEffect("prohibit", {
  prohibit_use = function(self, player, card) -- 允许被转换
    if LB_U.isBackCards(card) then
      return #card.subcards == 0
    end
  end,
  prohibit_response = function(self, player, card)
    if LB_U.isBackCards(card) then
      return #card.subcards == 0
    end
  end,
  prohibit_discard = function(self, player, card)
    --仅处理火攻的情况
    if LB_U.isBackCards(card) then
      if Fk.currentResponseReason == "fire_attack_skill" then
        return true
      elseif RoomInstance then
        local event = RoomInstance.logic:getCurrentEvent()
        if event.event == GameEvent.SkillEffect then
          local data = event.data
          if data.skill.trueName == "fire_attack_skill" then
            return true
          end
        end
      end
    end
  end
})

BackCards:addEffect("filter", {
  mute = true,
  card_filter = function(self, card, player)
    return table.contains(player:getCardIds("h"), card.id) and LB_U.isBackCards(card)
  end,
  view_as = function(self, player, card)
    --通过这种方式禁用special_skills
    local c = Fk:cloneCard(card.name, card.suit, card.number)
    c.special_skills = nil
    return c
  end,
})

return BackCards
